<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>资质证书管理</title>
    <link rel="stylesheet" type="text/css" href="../../lib/pagination/style/pagination.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/base.css"/>
    <link rel="stylesheet" type="text/css" href="/css/base/base.css?20201106.1"/>
    <link rel="stylesheet" type="text/css" href="../../css/news/center.css"/>
    <link rel="stylesheet" href="/lib/laydate/need/laydate.css">
    <link rel="stylesheet" href="/lib/laydate/skins/default/laydate.css">
    <link rel="stylesheet" href="/lib/layui/layui/css/layui.css?20190817.1">
    <script type="text/javascript" src="../../js/news/jquery-1.9.1.js"></script>
    <script type="text/javascript" src="/js/base/tablePage.js"></script>
    <script src="../../js/news/page.js"></script>
    <script src="../../js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../lib/layer/layer.js?20201106"></script>
    <script src="../../lib/laydate/laydate.js"></script>
    <script src="/lib/layui/layui/layui.js"></script>
    <script src="../js/sys/citys.js" type="text/javascript" charset="utf-8"></script>

    <style>
        * {font-family: "Microsoft Yahei" !important;}
        .header{
            margin-top: 15px;
            height: 40px;
        }
        .header .title{
            margin-left: 22px;
        }
        .header span{
            float: none;
            font-size: 22px;
            color: #333;
            display: inline-block;
            margin-left: 10px;
            vertical-align: middle;
            margin-top: -6px;
        }
        .content_label{
            line-height: 28px;
            font-size: 15px;
            color: rgb(111, 111, 111);
        }
        .content_label ul li{
            height: 16px;
            line-height: 16px;
            padding: 5px 12px;
            margin: 25px 0px;
            font-size: 15px;
            border-radius: 3px;
            display: inline;
        }
        .content_label ul{
            margin: 15px 0;
        }

        .pagediv table thead {
            background: white;
            line-height: 40px;
            border-bottom: 1px #dddddd solid;
            font-size: 13pt;
            color: #2F5C8F;
            font-weight: bold;
            height: 50px;
            border: 0px;
        }
        .pagediv tr:hover {
            background-color: #D3E7FA;
        }
        .pagediv tr:nth-child(odd) {
            background-color: #F6F7F9;
        }
        .pagediv tr:nth-child(odd) {
            background-color: #F6F7F9;
        }
        .queries{
            padding: 10px 0;
            height: 40px;
            position: relative;
        }
        #pageTbody tr{
            height: 40px;
        }
        .editAndDelete2{
            color: red;
        }
        .editAndDelete0{
            color: #2b7fe0;
        }
        .editAndDelete1{
            color: 2b7fe0;
        }
        #pop-up{
            height: 100%;
            position: fixed;
            top: -2px;
            right: -600px;
            display: none;
        }
        #keyWords{
            width: 130px;
            height: 30px;
            padding-left: 5px
        }
        .index_content_1 .one{
            color: white;
            padding: 4px;
        }
        .index_content_2 .one{
            color: white;
            padding: 4px;
        }

        #supplierImport{
            width: 120px;
            height: 30px;
            border: none;
            color: #fff;
            cursor: pointer;
            padding: 4px;
            padding-left: 35px;
            background-image: url(../../img/import/import.png);
            margin-top: -4px ;
        }
        #supplierExport{
            background-image: url(../../img/import/export.png);
            width: 120px;
            height: 30px;
            border: none;
            color: #fff;
            cursor: pointer;
            padding: 4px;
            padding-left: 35px;
            margin-top: -4px ;
        }
        .one{
            width: 120px;
            height: 30px;
            border: none;
            color: #fff;
            cursor: pointer;
            padding: 5px;
        }

        /*单选框字体加粗*/
        .radiofont{
            font-weight: bold;
            font-size: large;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>
</head>
<body>
<!--head开始-->
<%--主页面--%>
<div class="indexZhu">
    <div class="header">
        <div class="title">
            <img src="/img/commonTheme/${sessionScope.InterfaceModel}/flow_run_title.png"><span style="">资质证书管理</span>
            <hr style="background-color: black"/>
        </div>
    </div>
</div>


<div class="layui-fluid" style="margin-top: 10px;">
    <div class="layui-row" style="display: flex;flex-direction: row;position: relative;">
        <div class="layui-form">
            <input type="radio" name="status" value=""  lay-filter="status"  title="全部证书" checked>
            <input type="radio" name="status" value="1"  lay-filter="status" title="一月内过期证书">
            <input type="radio" name="status" value="2"  lay-filter="status" title="已过期证书">
        </div>

        <div class="layui-form">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">证件照名称</label>
                    <div class="layui-input-inline">
                        <input type="text" name="certName" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">法人</label>
                    <div class="layui-input-inline">
                        <input type="text" name="lawName" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-inline">
                    <button type="button" name="LOL" class="layui-btn">查询</button>
                </div>
            </div>
        </div>
    </div>



    <div class="layui-row">
        <table id="pagediv"  lay-filter="pagediv"></table>
    </div>
</div>

</body>
<script type="text/html" id="doSth">
    <a class="layui-btn layui-btn-xs layui-btn-danger" style="width: 28%;" lay-event="xiangqing">详情</a>
    <a class="layui-btn layui-btn-xs layui-btn-light" style="background-color:#2B7FE0;width: 28%" lay-event="agree">编辑</a>
    <a class="layui-btn layui-btn-xs layui-btn-danger" style="width: 28%;background:red " lay-event="disagree">删除</a>
</script>
<script>
    var table,form,laydate,upload,layedit,layer;

    //查询
    $('button[name="LOL"]').click(function () {
        table.reload('pagediv', {
            where: {
                certName: $('input[name="certName"]').val(),
                lawName: $('input[name="lawName"]').val()
            }
        })
    });

    $(function() {
        layui.use(['table', 'form', 'laydate', 'upload', 'element', 'layedit'], function () {
            table = layui.table,
                form = layui.form,
                laydate = layui.laydate,
                upload = layui.upload,
                layer = layui.layer,
                layedit = layui.layedit;

            //渲染表格
            table.render({
                elem: '#pagediv' //指定原始表格元素选择器（推荐id选择器）
                ,url:'/crmCertificate/selectByCertificates'
                ,where:{
                    status : ''
                }
                ,page:true
                ,limit:10
                ,cols: [[
                    {field:'lawName',title:'法人',align:'center'}
                    ,{field:'profession',title:'相关专业',align:'center'}
                    ,{field:'contactPerson',title:'联系人电话',align:'center'}
                    ,{field:'contractNo',title:'合同编号',align:'center'}
                    ,{field:'email',title:'电子邮件',align:'center'}
                    ,{field:'address',title:'地址详情',align:'center'}
                    ,{field:'certName',title:'证件照名称',align:'center'}
                    ,{field:'',title:'操作',align:'center',toolbar:'#doSth',width:220}
                ]]//设置表头
                ,parseData: function(res){ //res 即为原始返回的数据
                    return {
                        "code": 0, //解析接口状态
                        "msg": res.msg, //解析提示文本
                        "count": res.totleNum, //解析数据长度
                        "data": res.obj //解析数据列表
                    };
                }
            });

            // //监听table
            table.on('tool(pagediv)', function (obj) {
                var event =obj.event
                var data = obj.data
                if (event =="disagree"){  //点击删除
                    layer.confirm('确定要删除吗?', {icon: 3, title: '提示'}, function (index) {
                        $.ajax({
                            type: 'get',
                            url: '/crmCertificate/deleteCertificate',
                            data: {
                                certId: data.certId
                            },
                            success: function (res) {
                                if (res.msg) {
                                    obj.del();
                                }
                                layer.close(index)
                            }
                        });
                    });
                }else if(event =="agree"){ //编辑
                    var agree=$('.saveBtn').attr('typeId')
                    window.location.href='/supplier/newAdd?isEdit=false&certId=' + data.certId;
                    // layer.open({
                    //     type: 2,
                    //     skin: false, //加上边框
                    //     area: ['100%', '100%'], //宽高
                    //     title: '编辑证书',
                    //     maxmin: true,
                    //     btn: ["确定", "取消"],
                    //     btnAlign: 'c',
                    //     content: '/supplier/newAdd?isEdit=false&certId=' + data.certId,
                    //     btn: ["确认", "取消"],
                    //     yes:function (index,layero) {
                    //         var arr = $(layero).find("iframe")[0].contentWindow.affrimFormat()
                    //         for(var i=0;i<arr.length;i++){
                    //             var email=arr[i].email;
                    //             var phone=arr[i].contactPerson;
                    //             var bo = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(email);
                    //             var bo1 = !(/^1[3456789]\d{9}$/).test(phone);
                    //             if(arr[i].lawName == '' ){
                    //                 layer.msg('请输入法人！', {icon: 2,time:1000});
                    //                 return false;
                    //
                    //             }else if(bo1 == true){
                    //                 layer.msg('请输入正确的联系电话！', {icon: 2,time:1000});
                    //                 return false;
                    //
                    //             }else if(bo == false){
                    //                 layer.msg('请输入正确的邮箱！', {icon: 2,time:1000});
                    //                 return false;
                    //
                    //             }else if(arr[i].profession == ''){
                    //                 layer.msg('请输入相关专业！', {icon: 2,time:1000});
                    //                 return false;
                    //
                    //             }else if(arr[i].createTime == ''){
                    //                 layer.msg('请选择成立时间！', {icon: 2,time:1000});
                    //                 return false;
                    //
                    //             }else if(arr[i].province == ''){
                    //                 layer.msg('请选择省！', {icon: 2,time:1000});
                    //                 return false;
                    //
                    //             }else if(arr[i].city == ''){
                    //                 layer.msg('请选择市！', {icon: 2,time:1000});
                    //                 return false;
                    //
                    //             }else if(arr[i].address == ''){
                    //                 layer.msg('请输入地址详情！', {icon: 2,time:1000});
                    //                 return false;
                    //
                    //             }else if(arr[i].certName == ''){
                    //                 layer.msg('请输入证件号名称！', {icon: 2,time:1000});
                    //                 return false;
                    //
                    //             }else if(arr[i].certNo == ''){
                    //                 layer.msg('请输入证件编号！', {icon: 2,time:1000});
                    //                 return false;
                    //
                    //             }else if(arr[i].certStartTime == ''){
                    //                 layer.msg('请选择证件照起始时间！', {icon: 2,time:1000});
                    //                 return false;
                    //
                    //             }else if(arr[i].certEndTime == ''){
                    //                 layer.msg('请选择证件照截止时间！', {icon: 2,time:1000});
                    //                 return false;
                    //
                    //             }else if(arr[i].remindTime == ''){
                    //                 layer.msg('请选择提醒时间！', {icon: 2,time:1000});
                    //                 return false;
                    //             }
                    //         }
                    //         $.ajax({
                    //             url:'/crmCertificate/updateByPrimaryKey',
                    //             dataType:'json',
                    //             type:'get',
                    //             data:{
                    //                 certId:data.certId,
                    //                 lawName:arr[0].lawName,
                    //                 contactPerson:arr[0].contactPerson,
                    //                 phone:arr[0].phone,
                    //                 createTime:arr[0].createTime,
                    //                 province:arr[0].province,
                    //                 city:arr[0].city,
                    //                 address:arr[0].address,
                    //                 contractNo:arr[0].contractNo,
                    //                 remark:arr[0].remark,
                    //                 certName:arr[0].certName,
                    //                 certNo:arr[0].certNo,
                    //                 certNumber:arr[0].certNumber,
                    //                 certStartTime:arr[0].certStartTime,
                    //                 certEndTime:arr[0].certEndTime,
                    //                 remindTime:arr[0].remindTime,
                    //                 attachmentName:arr[0].attachmentName,
                    //                 attachmentId:arr[0].attachmentId,
                    //             },
                    //             success: function (data) {
                    //                 layer.close(index);//关闭子页面
                    //                 table.reload('pagediv')
                    //             }
                    //         })
                    //     }
                    // })
                }else if(event =="xiangqing"){  //详情
                    window.location.href='/supplier/newAdd?editXia=2&isEdit=false&certId=' + data.certId;
                    var index = layer.open({
                        type: 2,
                        skin: false, //加上边框
                        area: ['100%', '100%'], //宽高
                        title: '查看详情',
                        maxmin: true,
                        btnAlign: 'c',
                        content: '/supplier/newAdd?isEdit=false&certId=' + data.certId,
                    })
                }
            });

            // //全部证书默认改变字体
            $('input[type="radio"][value=""]').next().find('div').addClass('radiofont');


            //监听顶部单选按钮
            form.on('radio(status)', function(data){
                var value = data.value;
                //选中的字体加粗
                $('input[type="radio"][name="status"]').next().find('div').removeClass('radiofont');
                $(data.elem).next().find('div').addClass('radiofont');
                //重载表格
                table.reload('pagediv', {
                    where:{
                        status:value
                    }
                });
            });
        });
    });

</script>

</html>
